package com.arnold.www.create;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @ClassName CreateThread_callable
 * @Description: 带返回参数的Callable
 * @Author Arnold
 * @Date 2020/4/3
 * @Version V2.0
 **/
public class CreateThread_callable implements Callable<Integer> {
    public Integer call() throws Exception {
        System.out.println("带返回参数的Callable执行");
        return 1;
    }

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        CreateThread_callable createThread_callable =new CreateThread_callable();
        FutureTask<Integer> futureTask = new FutureTask<Integer>(createThread_callable);
        Thread thread = new Thread(futureTask);
        thread.start();
        System.out.println("异步可先做其他业务逻辑！！！！");
        System.out.println( futureTask.get());
    }
}